<template>
  <view class="content">
    <concern-banner ref="concern"></concern-banner>
    <view class="tips-box"></view>
    <view class="info-box">
      <view class="info-block">
        <view class="tips-content">报数起卦</view>

        <view class="section">
          <view class="section-title">数字一：</view>
          <view class="section-content">
            <input
              v-model="number1"
              class="name input_text"
              placeholder="请输入0以上的数字"
              type="number"
            />
          </view>
        </view>
        <view class="section">
          <view class="section-title">数字二：</view>
          <view class="section-content">
            <input
              v-model="number2"
              class="name input_text"
              placeholder="请输入0以上的数字"
              type="number"
            />
          </view>
        </view>
        <view class="section">
          <view class="section-title">加时辰：</view>
          <view class="section-content">
            <view @click="addTimeClick1" class="select-item-box">
              <image
                class="select-item"
                :src="
                  addTime === true
                    ? '../../../static/images/bazi/cir1.png'
                    : '../../../static/images/bazi/cir2.png'
                "
              ></image>
              <view>是</view>
            </view>
            <view @click="addTimeClick2" class="select-item-box">
              <image
                class="select-item"
                :src="
                  addTime === true
                    ? '../../../static/images/bazi/cir2.png'
                    : '../../../static/images/bazi/cir1.png'
                "
              ></image>
              <view>否</view>
            </view>
          </view>
        </view>
        <view class="btn-box">
          <view @click="bindQuery" class="quiryButton">
            <view class="btn-text">立即起卦</view>
          </view>
        </view>
      </view>
    </view>
    <activity-box :positionId="303"></activity-box>
    <yipu-logo></yipu-logo>
  </view>
</template>

<script>
var e = require("@/utils/interopRequireDefault")(require("@/utils/meihua/getDateFn.js"));
var n = new (require("@/utils/meihua/calendarConverterFn.js").CalendarConverter)();
var t =
  (new (require("@/utils/meihua/listsFn.js").Lists)(),
  new (require("@/utils/meihua/siZhuInfo.js").SiZhuInfo)());

import { mapGetters } from "vuex";
export default {
  data() {
    return {
      addTime: false,
      number1: "",
      number2: "",
    };
  },
  computed: {
    ...mapGetters({
      isConcern: "user/isConcern",
    }),
  },
  methods: {
    // 添加时辰
    addTimeClick1: function () {
      this.addTime = true;
    },
    addTimeClick2: function () {
      this.addTime = false;
    },
    bindQuery: function (a) {
      if (this.isConcern == true) {
        var i = parseInt(this.number1);
        var o = parseInt(this.number2);
        var l = this.addTime;
        if (0 == i || 0 == o || isNaN(i) || isNaN(o)) {
          uni.showToast({
            title: "请输入大于0的数字",
            icon: "none",
            duration: 1e3,
          });
        } else {
          var r = new Date().getHours(),
            s =
              "子丑寅卯辰巳午未申酉戌亥"[(w = Math.floor(((r + 1) % 24) / 2) + 1) - 1] +
              "时";
          var u = 1,
            d = 1,
            c = 1,
            f = 1,
            g = 3;
          // fix: 数字算法修改为数字各个位相加后再取余,而非直接取余
          let temp1 = i.toString();
          let num1 = 0;
          for (let ele of temp1) {
            num1 += parseInt(ele);
          }
          // 第一个数上挂:除8取余
          if (num1 > 0 && num1 <= 8) u = num1;
          else {
            var h = num1 % 8;
            u = 0 === h ? 8 : h;
          }
          let temp2 = o.toString();
          let num2 = 0;
          for (let ele of temp2) {
            num2 += parseInt(ele);
          }
          // 第二个数下挂:除8取余
          if (num2 > 0 && num2 <= 8) d = num2;
          else {
            var v = num2 % 8;
            d = 0 === v ? 8 : v;
          }
          // 本卦 除6取余
          if ((l ? ((f = i + o + w), (g = 5)) : (f = num1 + num2), f > 0 && f <= 6))
            c = f;
          else {
            var D = f % 6;
            c = 0 === D ? 6 : D;
          }
          var w,
            m = (0, e.default)(new Date(), "Y"),
            y = (0, e.default)(new Date(), "M"),
            p = (0, e.default)(new Date(), "D"),
            b =
              ((s = "子丑寅卯辰巳午未申酉戌亥"[
                (w = Math.floor(((new Date().getHours() + 1) % 24) / 2) + 1) - 1
              ]),
              new Date(m, y - 1, p)),
            M = n.solar2lunar(b),
            q = t.getSiZhu(M.cDay, w) + s,
            N = t.getKongWang(M.cDay),
            S = {
              type: g,
              sg: u,
              xg: d,
              dy: c,
              sc: w,
              number1: i,
              number2: o,
              gonli: (0, e.default)(new Date(), "Y年M月D日 h:m"),
              nongli: M.cYear + "年" + M.lunarMonth + "月" + M.lunarDay + "日" + s + "时",
              sizhu: M.cYear + " " + M.cMonth + " " + M.cDay + " " + q + " (" + N + "空)",
            },
            j = "/pages/meihua/details/details?info=" + JSON.stringify(S);
          uni.navigateTo({
            url: j,
          });
        }
      } else {
        this.$refs.concern.concernPopup();
      }
    },
  },
};
</script>

<style scoped>
.content {
  height: 100%;
  width: 100%;
  overflow-y: scroll;
  position: relative;
}
.tips-box {
  height: 400rpx;
  background-color: #c6a680;
  width: 100%;
}
.tips-content {
  width: 100%;
  height: 31rpx;
  text-align: center;
  font-size: 32rpx;
  font-weight: bold;
  font-stretch: normal;
  line-height: 34rpx;
  letter-spacing: 0rpx;
  color: #32312e;
  margin: 94rpx auto 98rpx;
}
.info-box {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin-top: -230rpx;
}
.info-block {
  background-color: #fff;
  width: 640rpx;
  height: fit-content;
  border-radius: 0rpx;
  box-shadow: 0 0 20rpx #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 48rpx;
}

.section {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
  margin-bottom: 40rpx;
}

.section-title {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  font-size: 32rpx;
}
.section-content {
  width: 422rpx;
  height: 88rpx;
  box-sizing: border-box;
  font-size: 32rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 30rpx;
}
.select-item-box {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding-right: 60rpx;
}
.select-item {
  height: 42rpx;
  width: 42rpx;
}
.btn-box {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 80%;
  margin-top: 40rpx;
}
.quiryButton {
  width: 521rpx;
  height: 78rpx;
  
  font-size: 32rpx;
  color: #fff;
  background-color: #1e1e1eff;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.btn-text {
  font-size: 32rpx;
  white-space: nowrap;
}
</style>
